package cn.yht.wang.config;

import cn.yht.wang.interceptors.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] swaggerPatterns = new String[]{"/swagger-ui/index.html","/swagger-ui.html","/swagger-resources/**", "/webjars/**", "/login/**","/api/account/login"};
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/api/*/*")
//                .addPathPatterns("/*/**")
                .excludePathPatterns(swaggerPatterns);
    }
}
